package com.globagames.isometric.core.model
{
	public class IsoTile
	{
		public var x2d:int;
		public var y2d:int;
		
		public var x3d:int;
		public var y3d:int;
		public var height:int = 0;
		public var _depth:int;
		
		public var design:Array = new Array();		
		public var references:Array = new Array();	
		
		public var isAuthorized:Boolean = true;
		
		public function IsoTile()
		{
		}
		public function clone()
		{
			var clone:IsoTile = new IsoTile();
			clone.x2d = x2d;
			clone.y2d = y2d;
			clone.x3d = x3d;
			clone.y3d = y3d;
			clone._depth = _depth;
			clone.design = design.slice();
			clone.height = height;
		}
		public function removeReference( complexObject:IIsoObject):Boolean {
			var i:int = references.indexOf(complexObject);
			if( i >= 0 ) {
				references.splice(i,1);
				return true;
			} 
			return false;
		}
		public function hasReference( complexObject:IIsoObject):Boolean {
			var i:int = references.indexOf(complexObject);
			if( i >= 0 ) {				
				return true;
			} 
			return false;
		}
		public function addReference( complexObject:IIsoObject):Boolean {
			var i:int = references.indexOf(complexObject);
			if( i >= 0 ) {				
				return false;
			}
			references.push(complexObject); 			
			return true;
		}
		public function triAllByDepth():void {
			references.sort(triByDepth);
		}
		public function triByDepth(g1:IIsoObject, g2:IIsoObject):int {
         	if( g1.depth < g2.depth) return -1;
         	else return 1;
        }

	}
}